package com.ssh.dao;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Component;

import com.ssh.model.Student;

@Component("studentDao")
public class StudentDAO
{
    private SessionFactory sessionFactory;
    
    public Student getStudentById (int id) {
        Session session = sessionFactory.getCurrentSession();
        Student stu = (Student) session.load(Student.class, id);
        return stu;
    }
    
    public void save(Student stu){
        Session session = sessionFactory.getCurrentSession();
        session.save( stu );
    }

    
    public SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
    @Resource
    public void setSessionFactory(SessionFactory sessionFactory)
    {
        this.sessionFactory = sessionFactory;
    }
}